import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
// 导入全局样式
import './assets/css/global.css'
// 导入自定义字体图标
import './assets/fonts/iconfont.css'
// 导入树形表格第三方运行依赖插件
import ZkTable from 'vue-table-with-tree-grid'
// 导入axios
import axios from 'axios'
// 导入富文本编辑器vue-quill-editor
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme

// 全局注册富文本编辑器vue-quill-editor
Vue.use(VueQuillEditor)

// 全局配置axios基准路径
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
Vue.prototype.$http = axios
axios.defaults.baseURL = ''
Vue.prototype.$get = axios
// 全局配置axios请求拦截器
axios.interceptors.request.use(config => {
  config.headers.Authorization = sessionStorage.getItem('token')
  return config
})
// 阻止显示生产模式 设置为true生产模式环境 false开发模式环境
Vue.config.productionTip = false

// 全局注册树形表格为自定义组件
Vue.component('tree-table', ZkTable)

// 全局注册时间过滤器
Vue.filter('dateFormat', function (date) {
  const timeDate = new Date(date * 1000)
  const YY = timeDate.getFullYear()
  const MM = timeDate.getMonth() + 1
  const DD = timeDate.getDate()
  const hh = timeDate.getHours()
  const mm = timeDate.getMinutes()
  const ss = timeDate.getSeconds()
  return `${YY}-${beautZero(MM)}-${beautZero(DD)} ${beautZero(hh)}:${beautZero(mm)}:${beautZero(ss)}`
})
// 时间补零
function beautZero (val) {
  val = val < 10 ? '0' + val : val
  return val
}

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
